<template>
  <div class="tabcontrol">
    <div v-for="(item,index) in title" class="tabitem"
         :class="{active:index===controlindex}" @click="tabclick(index)">
      <span>{{item}}</span></div>
  </div>
</template>

<script>
export default {
name: "TabControl",
  props:{
  title:{
    type:Array,
    default(){
      return []
    }
  }
  },
  data(){
  return{
    controlindex:0
  }
  },
  methods:{
  tabclick(index){
    this.controlindex=index
    this.$emit('tabclick',index)
  }
  }
}
</script>

<style scoped>
.tabcontrol{
  display: flex;
  text-align: center;
  font-size: 16px;
  background-color: #fff;
}
.tabitem{
  flex: 1;
  height: 40px;
  line-height: 40px;

}
.active{
  color: var(--color-tint);

}
.tabitem span{
  padding: 5px;
}
.active span{
  border-bottom: 3px solid var(--color-tint);
}
</style>
